package com.future.mayi.response;


import android.text.TextUtils;

import com.future.baselib.entity.BaseResponse;
import com.future.mayi.app.App;
import com.future.mayi.model.LevelupModel;
import com.future.mayi.model.OrderNumModel;
import com.future.mayi.model.SaleModel;
import com.future.mayi.model.UserInfoModel;

import org.json.JSONException;
import org.json.JSONObject;


public class MyIndexResponse extends BaseResponse {

    public UserInfoModel userInfoModel;
    public OrderNumModel orderNumModel;
    public SaleModel saleModel;
    public LevelupModel levelupModel;
    public int msgCount;

    @Override
    public void parseInfo(String content) throws JSONException {
        if (!TextUtils.isEmpty(content)) {
            JSONObject object = new JSONObject(content);
            msgCount = object.getInt("msg_num");


            String userinfo = object.optString("user_info");
            if (!TextUtils.isEmpty(userinfo))
                userInfoModel = App.getGson().fromJson(userinfo, UserInfoModel.class);

            String order = object.optString("order_info");
            if (!TextUtils.isEmpty(order))
                orderNumModel = App.getGson().fromJson(order, OrderNumModel.class);

            String sale = object.optString("sale");
            if (!TextUtils.isEmpty(sale))
                saleModel = App.getGson().fromJson(sale, SaleModel.class);


            String levelup = object.optString("levelup");
            if (!TextUtils.isEmpty(levelup))
                levelupModel = App.getGson().fromJson(levelup, LevelupModel.class);

        }
    }
}
